Add make setup: discover the machine instead of assuming it - #3
Merged
Conversation
Every prerequisite in v0.1.0 was a hardcoded default that happened to be true
on one workstation. check-env validated those assumptions rather than
discovering the machine, and there was nowhere to record a per-machine answer
— so each new host rediscovered its own paths by failing a build, and each fix
so far has been a slightly better guess hardcoded in the same place.
scripts/setup.sh does the discovery. It finds every CUDA toolkit and gcc/g++
pair on the machine, reads the gcc cap out of the chosen toolkit's own
crt/host_config.h, and compiles a real CUDA translation unit with the pair you
pick. That last step is the point: nvcc -ccbin on a three-line kernel takes
three seconds and is the only evidence that a toolkit and a host compiler
actually agree. A version table is inference, and it goes stale one CUDA
release later. When they disagree, the compile wins.
The scan covers PATH, the usual distro and /opt prefixes, asdf installs, and
CONCEIT_CC_SEARCH_PATH. That last one is not an escape hatch: a toolchain you
built from source is precisely the one PATH does not know about, which is the
case that motivated this.
Answers persist to conceit.env, gitignored because it describes one machine.
cuda-env.sh sources it ahead of every default, and each line is itself a
${VAR:-default}, so the precedence chain stays readable: exported by hand >
this machine's intake > the guesses in cuda-env.sh. check-env now points at
`make setup` instead of naming a package.
.agents/skills/env-intake/SKILL.md wraps the script for the parts a scan
cannot decide: which toolkit a machine standardizes on when several are
installed, where an unpackaged toolchain lives, and whether a failed smoke
test means "pick another compiler" or "this machine needs a package." It also
says not to reach for -allow-unsupported-compiler, which trades a five-second
failure for a corrupt build hours later.
Verified on this machine (CUDA 13.3, gcc 16 default with gcc 15 alongside):
auto mode picks gcc-15 and compiles clean; interactively picking gcc 16 fails
the smoke test with nvcc's own "gcc versions later than 15 are not supported"
and re-prompts; a clean shell sourcing cuda-env.sh inherits the file; a
hand-exported CC still overrides it; check-env passes on the result. Caught
one bug in the process — nvidia-smi prints a driver/library version mismatch
on stdout in the same shape as a result, which sailed straight into the arch
list until the caps were filtered to well-formed values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2 — merge that first, and GitHub will retarget this to
main.Answers the question #1 and #2 kept dodging: why is there no intake step? Every prerequisite in v0.1.0 was a hardcoded default that happened to be true on one workstation.
check-envvalidated those assumptions rather than discovering the machine, and there was nowhere to record a per-machine answer — so each new host rediscovers its own paths by failing a build, and each fix so far has been a slightly better guess hardcoded in the same place.scripts/setup.sh/usr/local/cuda*,/opt/cuda*,$CUDA_HOME,nvccon PATH) and every gcc/g++ pair (PATH, distro prefixes,/opt/*/bin, asdf installs, andCONCEIT_CC_SEARCH_PATH). That last one is not an escape hatch — a toolchain built from source is precisely the one PATH does not know about, which is the case that motivated this.crt/host_config.h, so the constraint comes from the toolkit rather than a README that goes stale one CUDA release later.nvcc -ccbinon a three-line kernel takes three seconds and is the only evidence that a toolkit and host compiler actually agree. Everything above it is inference; when they disagree, the compile wins. A failure prints nvcc's own diagnostic and re-prompts.conceit.env(gitignored — it describes one machine), sourced bycuda-env.shahead of every default. Each line is itself a${VAR:-default}, so precedence reads: exported by hand > this machine's intake > the guesses incuda-env.sh..agents/skills/env-intake/SKILL.mdThe directed workflow around the script, for what a scan cannot decide: which toolkit a machine standardizes on when several are installed, where an unpackaged toolchain lives, and whether a failed smoke test means "pick another compiler" or "this machine needs a package." It also says plainly not to reach for
-allow-unsupported-compiler, which trades a five-second failure for a corrupt build hours later. Symlinked into.cursor/skills/likebuild-triage.Verification
On a box with CUDA 13.3, gcc 16 as the system default and gcc 15 alongside:
gcc-15and compiles cleangcc versions later than 15 are not supportedand re-promptscuda-env.shinherits the file; a hand-exportedCCstill overrides itmake check-envpasses on the resultmake checkpasses with the CI-pinned shellcheck 0.11.0; skill frontmatter validatesCaught one bug in my own code while testing:
nvidia-smion a host with a driver/library version mismatch prints that error to stdout, in the same shape as a result, and it sailed straight intoTORCH_CUDA_ARCH_LISTuntil the compute caps were filtered to well-formed values.